package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.ShoppingCart;
import com.sky.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

import static com.sky.enumeration.OperationType.INSERT;

@Mapper
public interface ShoppingCartMapper {

@Update("update shopping_cart set number=#{number} where id = #{id} ")
    void update(ShoppingCart shoppingCart);

    List<ShoppingCart> list(ShoppingCart shoppingCart);
@Insert("insert into shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) VALUES " +
        "(#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
@AutoFill(INSERT)
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param currentId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long currentId);
@Delete("delete from shopping_cart where id = #{id}")
    void delete(ShoppingCart cart);
}
